<template>
    <div id="dialog-container">
        <el-dialog v-dialogDrag 
            title="专用检具历史记录卡" append-to-body
            :visible.sync="dialogVisible" @close="$emit('update:show', false)" :before-close="handleClose" :show="show"
            :close-on-click-modal="false" width="760px">
            <el-form :model="form" :inline="true" size="small" label-width="130px">
                <el-row type="flex" justify="center" style="margin-bottom: 10px;">
                    <h2>专用检具历史记录卡</h2>
                </el-row>
                <el-row>
                    <el-col :span="12" :offset="12">
                        <el-form-item label="任务单号：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="企业名称：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="存放地点：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="检定部门：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="零件名称：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="生产厂家：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="检具名称：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="工序号：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="计量编号：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="检定日期：">
                            <el-date-picker v-model="form.date" type="date" placeholder="选择日期"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="附件：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="说明：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="使用部门：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="统一编号：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <hr>
                <el-row type="flex" justify="center">
                    <el-button type="primary" size="mini" round>周期检定结果</el-button>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="检定项目：">
                            <el-checkbox-group v-model="form.checkList" style="width: 500px;">
                                <el-checkbox label="校前状态" style="width: 140px;"></el-checkbox>
                                <el-checkbox label="定位面平整" style="width: 122px;"></el-checkbox>
                                <el-checkbox label="台阶标记明显" style="width: 170px;"></el-checkbox>
                                <el-checkbox label="外观整洁" style="width: 140px;margin-left: 0;"></el-checkbox>
                                <el-checkbox label="压紧装置有效" style="width: 122px;"></el-checkbox>
                                <el-checkbox label="调整位置明确，漆封固定标志" style="width: 170px;"></el-checkbox>
                                <el-checkbox label="活动部门正常移动周转" style="width: 140px;margin-left: 0;"></el-checkbox>
                                <el-checkbox label="锁紧与松开有效"></el-checkbox>
                                <el-checkbox label="适用性"></el-checkbox>
                            </el-checkbox-group>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="检定日期：">
                            <el-date-picker v-model="form.date" type="date" placeholder="选择日期"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="检定人：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="下次检定日期：">
                            <el-date-picker v-model="form.date" type="date" placeholder="选择日期"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="检定结果：">
                            <el-select v-model="form.departmentVal" placeholder="请选择" style="width: 200px;">
                                <el-option v-for="item in form.department"
                                    :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select> 
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="附件：">
                            <el-upload
                                class="upload-demo"
                                action="https://jsonplaceholder.typicode.com/posts/"
                                :on-preview="handlePreview"
                                :on-remove="handleRemove"
                                :before-remove="beforeRemove"
                                multiple
                                :limit="3"
                                :on-exceed="handleExceed"
                                :file-list="fileList">
                                <el-button size="small" type="primary">点击上传</el-button>&nbsp;&nbsp;&nbsp;
                                <span slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</span>
                            </el-upload>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="备注：">
                            <el-input v-model="form.name" type="textarea" :row="3" style="width: 552px;"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
                <el-button @click="dialogVisible = false">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                dialogVisible: this.show,
                form: {
                    name: '',
                    data: '',
                    checkList: []
                },
                fileList: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}],
            }
        },
        props: {
            show: {
                type: Boolean,
                default: false
            }
        },
        watch: {
            show() {
                this.dialogVisible = this.show;
            }
        },
        methods: {
            handleClose() {
                this.dialogVisible = false;
            },
            // 文件上传
            handleRemove(file, fileList) {
                console.log(file, fileList);
            },
            handlePreview(file) {
                console.log(file);
            },
            handleExceed(files, fileList) {
                this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
            },
            beforeRemove(file, fileList) {
                return this.$confirm(`确定移除 ${ file.name }？`);
            }
        }
    }
</script>

<style scoped>
    .el-date-editor.el-input{
        width: 200px;
    }
    .el-button--mini, .el-button--mini.is-round{
        padding: 5px 10px;
        margin-bottom: 10px;
    }
</style>

